// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.

#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
#define CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_

#include "include/cef_app.h"
#include "include\wrapper\cef_message_router.h"

#include "simple_handler.h"

// Implement application-level callbacks for the browser process.
class SimpleApp : public CefApp
  , public CefBrowserProcessHandler
{
 public:
  SimpleApp(){}

  // CefApp methods:
  CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
    return this;
  }
  void OnContextInitialized() override;  
 private:
  // Include the default reference counting implementation.
  IMPLEMENT_REFCOUNTING(SimpleApp);
};

class SimpleAppRender :public CefApp
    , public CefRenderProcessHandler{
  public:
    SimpleAppRender();

    CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()override{ 
      return this; 
    }
    void OnContextCreated(CefRefPtr<CefBrowser> browser,
                                CefRefPtr<CefFrame> frame,
                                CefRefPtr<CefV8Context> context);
    void OnBeforeCommandLineProcessing(const CefString& process_type,
                                            CefRefPtr<CefCommandLine> command_line) override;
    //CefBrowserProcessHandler methods:
    void OnWebKitInitialized() override;
    bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
                                    CefRefPtr<CefFrame> frame,
                                    CefProcessId source_process,
                                    CefRefPtr<CefProcessMessage> message)override;
    CefRefPtr<CefMessageRouterRendererSide> m_renderer_side_router;
  private:
  // Include the default reference counting implementation.
    IMPLEMENT_REFCOUNTING(SimpleAppRender);
};
#endif  // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
